package com.catmiao.ai.controller;

import dev.langchain4j.community.model.dashscope.WanxImageModel;
import dev.langchain4j.data.image.Image;
import dev.langchain4j.data.message.ImageContent;
import dev.langchain4j.data.message.TextContent;
import dev.langchain4j.data.message.UserMessage;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.chat.response.ChatResponse;
import dev.langchain4j.model.output.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Base64;

@RestController
@Slf4j
public class ImageController {

    @Autowired
    private WanxImageModel wanxImageModel;




    @GetMapping("/image/generator")
    public String readImageContent(@RequestParam String prompt) throws Exception {

        Response<Image> imageResponse = wanxImageModel.generate(prompt);


        log.info("图片外链: {}", imageResponse.content().url());

        return imageResponse.content().url().toString();
    }

}